/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.view.statementView;
/**
 * 说明：
 * 销售报表主界面
 * @Author：黄盛强
 * @Date：2012-03-21
 */
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;

import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import com.ruipengkj.component.jlist.ListButtonCellRenderer;
import com.ruipengkj.component.jlist.ListNodeButton;
import com.ruipengkj.component.jlist.StatementListPanel;
import com.ruipengkj.view.base.BasePanel;

public class StatementSalesPanel extends BasePanel implements ListSelectionListener {
private static final long serialVersionUID = 1L;
	
	private StatmentOrderSummary statmentOrderSummary;//销售订单汇总表显示按钮
//	private StatmentOrderDetails statmentOrderDetails;//销售订单明细表
	private StatmentYearSales statmentYearSales;//年度销售报表
	private StatmentMonthlySales statmentMonthlySales;//月度销售报表
	private StatmentDaySales statmentDaySales;//日销售报表
//	private StatmentDaySales statmentDaySales;//日期销售报表
	private StatementCommoditySalesSummary statementCommoditySales;//商品销售汇总表
	private StatementCommoditySalesReturnSummary statementCommoditySalesReturnSummary;//商品销售退货汇总表
	private StatementMenberSalesSummary statementMenberSalesSummary;//会员销售汇总表
	private CardLayout right_layout;
	private JPanel right_panel;
	private DefaultListModel listModel;
	private JList btnList;//功能按钮列表
	public StatementSalesPanel() {
		this.setLayout(new BorderLayout());
		this.init();
	}
	
	private void init() {
		listModel=new DefaultListModel();
		listModel.addElement(new ListNodeButton("销售订单汇总表"));
//		listModel.addElement(new JLabel("销售订单明细表",SwingUtil.getOpenSwingImage("statements_statment_order_details.png"),JLabel.CENTER));
		listModel.addElement(new ListNodeButton("商品销售汇总表"));
		listModel.addElement(new ListNodeButton("商品销售退货汇总表"));
		listModel.addElement(new ListNodeButton("年度销售报表"));
		listModel.addElement(new ListNodeButton("月度销售报表"));
		listModel.addElement(new ListNodeButton("每日销售报表"));
		listModel.addElement(new ListNodeButton("会员销售汇总表"));
		btnList=new StatementListPanel();
		btnList.setFixedCellHeight(35);
		btnList.setModel(listModel);
		btnList.setCellRenderer(new ListButtonCellRenderer());
		btnList.addListSelectionListener(this);
		btnList.setBackground(new Color(245, 250, 255));
		JSplitPane jsp = new JSplitPane();
		jsp.add(btnList, JSplitPane.LEFT, 0);
		jsp.add(initRight(), JSplitPane.RIGHT, 0);
		jsp.setDividerLocation(180);
		this.add(jsp, BorderLayout.CENTER);
		this.add(uiFactory.createFlowJPanel(), BorderLayout.SOUTH);
	}
	
	private JPanel initRight() {
		right_layout = new CardLayout();
		right_panel = new JPanel(right_layout);
		
		statmentOrderSummary = new StatmentOrderSummary();
   		right_panel.add(statmentOrderSummary, "a");
		right_layout.show(right_panel, "a");
		SwingUtilities.invokeLater(statmentOrderSummary);
		return right_panel;
	}
	
	@Override
	public void clear() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void valueChanged(ListSelectionEvent e) {
		switch(btnList.getSelectedIndex()){
       	case 0:{
       		//销售订单汇总表
       		statmentOrderSummary = new StatmentOrderSummary();
       		right_panel.add(statmentOrderSummary, "a");
			right_layout.show(right_panel, "a");
			SwingUtilities.invokeLater(statmentOrderSummary);
       		break;}
//       	case 1:{
//       		//销售订单明细表
//       		statmentOrderDetails = new StatmentOrderDetails();
//       		right_panel.add(statmentOrderDetails, "b");
//			right_layout.show(right_panel, "b");
//			SwingUtilities.invokeLater(statmentOrderDetails);
//       		break;}
       	case 1: {
			// 商品销售汇总表
			statementCommoditySales = new StatementCommoditySalesSummary();
			right_panel.add(statementCommoditySales, "c");
			right_layout.show(right_panel, "c");
			SwingUtilities.invokeLater(statementCommoditySales);
			break;
		}
     	case 2: {
			// 商品销售退货汇总表
     		statementCommoditySalesReturnSummary = new StatementCommoditySalesReturnSummary();
			right_panel.add(statementCommoditySalesReturnSummary, "d");
			right_layout.show(right_panel, "d");
			SwingUtilities.invokeLater(statementCommoditySalesReturnSummary);
			break;
		}
     	case 3:{
       		//年度销售报表
       		statmentYearSales = new StatmentYearSales();
       		right_panel.add(statmentYearSales, "g");
			right_layout.show(right_panel, "g");
			SwingUtilities.invokeLater(statmentYearSales);
       		break;
       	}
       	case 4:{
       		//月度销售报表
       		statmentMonthlySales = new StatmentMonthlySales();
       		right_panel.add(statmentMonthlySales, "e");
			right_layout.show(right_panel, "e");
			SwingUtilities.invokeLater(statmentMonthlySales);
       		break;
       	}
       	case 5:{
       		//每日销售报表
       		statmentDaySales = new StatmentDaySales();
       		right_panel.add(statmentDaySales, "h");
			right_layout.show(right_panel, "h");
			SwingUtilities.invokeLater(statmentDaySales);
       		break;
       	}
       	case 6:{
       		//会员销售汇总表
    		statementMenberSalesSummary = new StatementMenberSalesSummary();
       		right_panel.add(statementMenberSalesSummary, "f");
			right_layout.show(right_panel, "f");
			SwingUtilities.invokeLater(statementMenberSalesSummary);
       		break;
       	}
       }
	}
}
